package com.ooqiu.gaming.ui.example;

import android.content.Intent;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ooqiu.gaming.R;
import com.ooqiu.gaming.api.GamingApi;
import com.ooqiu.gaming.base.BaseActivity;
import com.ooqiu.gaming.components.retrofit.progress.ProgressSubscriber;
import com.ooqiu.gaming.utils.LogUtil;
import com.umeng.socialize.UMShareAPI;

import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = StylePreviewActivity.PATH)
public class StylePreviewActivity extends BaseActivity {

    public static final String PATH = "/gn/test/style_preview";


    @BindView(R.id.btn_share)
    Button mBtnShare;

    GamingApi mGamingApi;

    @Override
    public int initContentView() {
        return R.layout.activity_style_preview;
    }

    @Override
    public void initInjector() {
        ButterKnife.bind(this);
        mGamingApi = getApplicationComponent().getGamingApi();
    }

    @Override
    public void initUiAndListener() {

    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isApplyStatusBarColor() {
        return false;
    }

    @Override
    protected Toolbar toolbarIdRes() {
        return null;
    }

    @Override
    protected View statusLayoutId() {
        return null;
    }

    @OnClick(R.id.btn_share)
    public void onClick() {
        aliPay();

//        wxPay();
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
    }


    private void aliPay() {
        String orderInfo = "app_id=2017112700195163&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22hr%40ooqiu.com%22%3A%22%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.01%22%2C%22subject%22%3A%22%E5%9C%88%E5%9C%88%E5%AF%BB%E5%AE%9D%22%2C%22body%22%3A%22%E5%9C%88%E5%9C%88%E5%AF%BB%E5%AE%9D%22%2C%22out_trade_no%22%3A%222018011286453%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fwww.ooqiuimg.com%2Falipay_notify.php&sign_type=RSA&timestamp=2018-01-12+18%3A01%3A45&version=1.0&sign=R6gLz3jYmRjsyUVSes0bjRXspjNjk7jp5YWf7kPETnlYq6o9psQoCccQHAR3T6d8ZZlwA4us0yyQQ9eBEiGxgwccJYodCfP1OmnDBnI881K%2FzQBMSEWRJhx8lDxuJ1N0kdzFxTkSIr6FTey8OkBOL5rMFNoC6DlJ8UhOlx2RXRU%3D";
        mGamingApi.aliPay(this, orderInfo)
                .subscribe(new ProgressSubscriber<Map<String, String>>(mContext) {
                    @Override
                    public void onStart() {

                    }

                    @Override
                    public void onNext(Map<String, String> res) {
                        LogUtil.e(res.toString());
                    }

                    @Override
                    public void onFinish() {

                    }
                });
    }

//    private void wxPay() {
//        mGamingApi.wxPay(mContext, "{\n" +
//                "    \"appid\": \"wx0e954a79ea059628\",\n" +
//                "    \"mweb_url\": null,\n" +
//                "    \"noncestr\": \"hIbM3grXIkmLwtZg\",\n" +
//                "    \"package\": \"Sign=WXPay\",\n" +
//                "    \"partnerid\": \"1493677432\",\n" +
//                "    \"prepayid\": \"wx201801121732513bb636b2440156086734\",\n" +
//                "    \"timestamp\": 1515749571,\n" +
//                "    \"sign\": \"51DBEE7343DB315733CA8FC24B058DF9\"\n" +
//                "}");
//    }


}
